﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using arcchallenge.servicecontracts;
using arcchallenge.servicecontracts.ebcpatterns;

namespace arcchallenge.host
{
    class MainBoard : IConfigure, IEntryPoint
    {
        private readonly IEntryPoint entrypoint;
        private readonly IEnumerable<IConfigurator> configurators;


        public MainBoard(IFrontend frontend, IDomainLogicBoard domainLogic, IConfigurator config)
        {
            frontend.Out_TransformToFile += domainLogic.In_TransformToFile;
            domainLogic.Out_TransformedLine += frontend.In_TransformedLine;

            config.Out_ConfigureDefaultDirectoryname += domainLogic.In_ConfigureDefaultPath;

            this.entrypoint = frontend;
            this.configurators = new[] {config};
        }


        public void Configure(string[] args)
        {
            foreach(var cfg in this.configurators)
                cfg.Configure(args);
        }


        public void Run(string[] args)
        {
            this.entrypoint.Run(args);
        }
    }
}
